﻿using System;
using System.Linq;
using System.Web;
using System.Collections.Generic;
using System.Text;


namespace HQWeb.View
{
    /// <summary>
    /// GetMenu 获得项目分类查询
    /// </summary>
    public class GetMenu : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            BLL.SysManage.T_PUB_PROJECTTYPE TypeBll = new BLL.SysManage.T_PUB_PROJECTTYPE();

            List<Model.SysManage.T_PUB_PROJECTTYPE> modelList = TypeBll.GetModelList("");
            StringBuilder strHtml = new StringBuilder();
            strHtml.Append("");
            IEnumerable <Model.SysManage.T_PUB_PROJECTTYPE > pList =modelList.Where(p => p.PARENT_ID == 0 || p.PARENT_ID == null);
            IEnumerable<Model.SysManage.T_PUB_PROJECTTYPE> cList;
            foreach (Model.SysManage.T_PUB_PROJECTTYPE item in pList)
            {
                strHtml.Append("<h3>");
                strHtml.Append(" <br /> <a href=\"#\" onclick=\"getsearchpage('" + item.PROJECTTYPE_ID+ "')\">" + item.PROJECTTYPE_NAME + "</a>");
                strHtml.Append("</h3>");
                #region 加载二级类型
                cList = pList.Where(p => p.PARENT_ID == item.PROJECTTYPE_ID);
                foreach (Model.SysManage.T_PUB_PROJECTTYPE citem in cList)
                {
                    strHtml.Append("<li><a href=\"#\" onclick=\"getsearchpage('" + item.PROJECTTYPE_ID+ "'>主持人</a> </li>");
                }
                strHtml.Append("</ul>");
                #endregion
            }
            context.Response.Write(strHtml.ToString());
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}